/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package exatrez.quartz;

import com.google.inject.Inject;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.Trigger;
import org.quartz.TriggerUtils;

/**
 *
 * @author Mansur
 */
public class AdminSchedulerManager {
    
    Scheduler scheduler;
    
    @Inject
    public AdminSchedulerManager(Scheduler scheduler){
        this.scheduler = scheduler;        
    }
    
    public void start() throws SchedulerException{
        JobDetail adminJob = new JobDetail("adminBatch", "adminEmail_group", CronAdminEmailJob.class);
        Trigger daily = TriggerUtils.makeDailyTrigger("admin_trigger",00,00);        
//        Trigger daily = TriggerUtils.makeMinutelyTrigger("admin_trigger");
        scheduler.scheduleJob(adminJob, daily);
        scheduler.start();
    }
    
    public void shutdown() throws SchedulerException{
        scheduler.shutdown();
    }
}
